<div class="main-body">
	<div class='panel'>
		<div class='header' style='height:28px;line-height:28px;'>
			<span class='col_fade'><span class="label label-important"><%=folder.name%></span> (共<span id="file_count_span" class="label label-important"><%=files.length%></span>个文件)</span>
			<div style='float:right;'>
				跳转到 <select class="span2" onchange="viewFolderFiles(this.value)" value='<%=folder.id%>'>
	              <%
	              	for(var i = 0; i < folders.length; i++){
	              		if(folders[i].id == folder.id){
	              %>
	                <option value='<%=folders[i].id%>' selected='selected'><%=folders[i].name%></option>
	              <%
	              		}else{
	              %>
	                <option value='<%=folders[i].id%>'><%=folders[i].name%></option>
	              <%
	              		}
	              	}
	              %>
	             </select>
			</div>
		</div>
		<table class='table folder_files_table' style="width:720px;margin:20px;">
			<thead>
				<th width=520px>文件名</th>
				<th width=60px>大小</th>
				<th width=60px>状态</th>
				<th width=80px>编辑</th>
			</thead>
			<tbody>
			<%-partial('vdisk/file_item',{collection:files,as:'file'}) %>
			</tbody>
		</table>
	</div>
</div>

<%-partial('user/profile',{object:locals.current_user.id, as:'user_id'})%>

<script>
	function setPrivate(fileId){
	    $.ajax({
	        type : "POST",
	        url : "/file/"+fileId+"/private",
	        success : function(data) {
	            if (data.flag == 'success') {
	                $('#isPublicLabel_'+fileId).html('私密');
	                $('#setVisibleLi_'+fileId).html('<a  href="javascript:void(0)" onclick="setPublic('+ fileId +')"><i class="icon-folder-open"></i> 设为公开</a>');
	            }
	        },
	        error : function() {}
	    });
	}
	function setPublic(fileId){
	    $.ajax({
	        type : "POST",
	        url : "/file/"+fileId+"/public",
	        success : function(data) {
	            if (data.flag == 'success') {
	                $('#isPublicLabel_'+fileId).html('公开');
	                $('#setVisibleLi_'+fileId).html('<a  href="javascript:void(0)" onclick="setPrivate('+ fileId +')"><i class="icon-ban-circle"></i> 设为私密</a>');
	            }
	        },
	        error : function() {}
	    });
	}
	function deleteFile(fileId){
	    if(confirm('确定要删除该文件?')){
	        $.ajax({
		        type : "POST",
		        url : "/file/"+fileId+"/delete",
		        success : function(data) {
		            if (data.flag == 'success') {
		                $('#file_tr_'+fileId).remove();
		                $('#file_count_span').html($('#file_count_span').text()-1);
		            }
		        },
		        error : function() {}
		    });
	    }
	}
	
	function viewFolderFiles(folderId){
	    window.location.href='/'+folderId+'/files';
	}
	
</script>

